import { useInitDataSingleton } from './shared';
import { BasXueYeLaiYuanApi, BasXueYeLaiYuanAllOutput } from '/@/api/bas/BasXueYeLaiYuan';

const { list, initList: getBasXueYeLaiYuanList } = useInitDataSingleton<BasXueYeLaiYuanAllOutput>(BasXueYeLaiYuanApi.all);

// 血液来源, 不常用资料, 按需加载
export { getBasXueYeLaiYuanList };

// 通过id获取
export async function getBasXueYeLaiYuan(id: number) {
	await getBasXueYeLaiYuanList();
	return list.value.find((item) => item.id == id);
}

// 获取默认血液来源
export async function getBasXueYeLaiYuanMoRen() {
	await getBasXueYeLaiYuanList();
	return list.value.find((item) => item.shiFouMoRen) ?? list[0];
}